﻿using System;
using System.Runtime.Serialization;

namespace Kernelx.Contexts.Repositories.Core
{

    /// <summary>
    /// 属性改动信息
    /// </summary> 
    [Serializable, DataContract]
    public class Alter<TKey>
    {
        /// <summary>
        /// 实体的属性信息
        /// </summary>
        [DataMember]
        public TKey Prop { get; set; }


        /// <summary>
        /// 原始值
        /// </summary>        
        [DataMember]
        public object OriginalValue { get; set; }

        /// <summary>
        /// 新的值
        /// </summary>
        [DataMember]
        public object NewValue { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Alter() { }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="prop"></param>
        /// <param name="originalValue"></param>
        /// <param name="newValue"></param>
        public Alter(TKey prop, object originalValue, object newValue)
        {
            if (prop == null)
                throw new ArgumentNullException($"参数{nameof(prop)}不能为null");
            Prop = prop;
            OriginalValue = originalValue;
            NewValue = newValue;
        }
    }



}
